package com.example.kotlintest

import kotlin.random.Random

class TestClass {
    var name:String?=null
    var age:Int = 0
    var home:String?=null
}
fun TestClass.getName(){
    this.name=Random.nextInt(111).toString()
}
fun TestClass.noHome()=this.apply {
    this.home="无家可归"
}
fun TestClass.growPeo()=this.apply {
    this.age=this.age+1
}

fun TestClass.toStr():String{
    return """{"name":"${this.name}","home":"${this.home}","age":${this.age}}""".prependIndent().trim()
}
